symbol ::= initialChar [ trailingChar ]*
initialChar ::= alphaChar | underscore
trailingChar ::= alphaChar | underscore | decimalDigit
nameLiteral ::= @ [ trailingChar ]+
arithOperator ::= + | - | * | /
negOperator ::= -
compOperator ::= = | == | <> | != | !== | < | > | <= | >=
integerConst ::= [ negOperator ] [ decimalDigit ]+
mantissa ::= integerConst [ .decimalDigit ] [ decimalDigit ]*
exponent ::= e integerConst
numericConst ::= mantissa [ exponent ]
| hexLiteral
hexConst ::= [ hexDigit ]+
hexLiteral ::= 0x [ hexDigit ]+
stringLiteral ::= " [ unicodeChar ]* "
unicodeChar ::= -- any printing char
| escapeChar
| \< hexConst >
alphaChar ::= a | b | c | . . . | x | y | z
decimalDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
hexDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f
underscore ::= _
escapeChar ::= \n | \r | \t
endOfLine ::= \n\r -- new line plus carriage return (OS/2 and Windows)
| \r -- carriage return (Macintosh)
| ;
endOfStream ::= -- end of stream
arrayLiteral ::= #( exprList )
| #( keyedList )
| #( )
| #( : )
exprList ::= simpleExpr [ , exprList ]*
keyedList ::= factor : simpleExpr [ , keyedList ]*
rangeLiteral ::= factor to factor [ by factor ]
| factor by factor [ by factor ]
| factor to factor [ inclOption ] continuous
| factor inclOption to factor [ inclOption ] continuous
inclOption ::= inclusive | exclusive
sentence ::= [ endOfLine ]* sentence
| topLevelExpr endOfStream
| topLevelExpr endOfLine
| endOfStream
topLevelExpr ::= simpleExpr
| globalExpr
| guardExpr
| assignmentExpr
| repeatExpr
| moduleExpr
| inModuleExpr
innerLevelExpr ::= expr
| localExpr
expr ::= simpleExpr
| guardExpr
| assignmentExpr
| repeatExpr
| blockControlExpr
simpleExpr ::= factor
| ifExpr
| caseExpr
| forExpr
| classDefExpr
| objectDefExpr
| functionDefExpr
| callExpr
| coercionExpr
| pipeExpr
| threadExpr
| arithmeticExpr
| pathExpr
| indexExpr
| rangeLiteral
factor ::= location
| numericConstant
| stringLiteral
| nameLiteral
| ?
| nextMethod
| anonFuncDefExpr
| compoundExpr
| arrayLiteral
compoundExpr ::= ( compoundExprSeq )
compoundExprSeq ::= innerLevelExpr moreExprs
moreExprs ::= endOfLine compoundExprSeq
| endOfLine [ moreExprs ]*
| empty
callExpr ::= factor paramSequence
| factor ( simpleExpr , paramList )
| factor ( symbol : factor [ , paramList ] )
| factor ( )
paramSequence ::= [ symbol : ] factor [ paramSequence ]
paramList ::= [ symbol : ] simpleExpr [ , paramList ]
blockControlExpr ::= continue
| exit [ with simpleExpr ]
| return [ simpleExpr ]
| throw again
coercionExpr ::= factor as factor
pipeExpr ::= | simpleExpr
threadExpr ::= simpleExpr &
arithmeticExpr ::= negOperator simpleExpr
| simpleExpr arithOperator simpleExpr
| simpleExpr compOperator simpleExpr
| simpleExpr contains simpleExpr
| not simpleExpr
| simpleExpr and simpleExpr
| simpleExpr or simpleExpr
assignmentExpr ::= location := simpleExpr
| location := assignmentExpr
| location := guardExpr
location ::= symbol
| ivAccess
| elementAccess
localExpr ::= local binding [ , binding ]*
| local funBindings
globalExpr ::= global binding [ , binding ]*
| global funBindings
binding ::= variable
funBindings ::= functionDefExpr [ , functionDefExpr ]*
| freeMethDefExpr [ , freeMethDefExpr ]*
variables ::= variable [ , variable ]*
variable ::= [ constant ] symbol [ restriction ] [ initialVal ]
restriction ::= { class factor }
| { kind factor }
| { object factor }
initialVal ::= : simpleExpr
| := simpleExpr
ivAccess ::= factor.symbol
elementAccess ::= factor [ simpleExpr ]
Flow of Control
ifExpr ::= if simpleExpr then expr else expr
| if simpleExpr then expr
| if simpleExpr do expr
caseExpr ::= case [ simpleExpr ] of taggedFormList end
taggedFormList ::= taggedForm moreTaggedForms
moreTaggedForms ::= [ endOfLine ]* taggedFormList
taggedForm ::= factor : expr
| otherwise : expr
repeatExpr ::= repeat while simpleExpr do expr
| repeat until simpleExpr do expr
| repeat expr while simpleExpr
| repeat expr until simpleExpr
forExpr ::= for forSources [ forTest ] forBody
forSources ::= forSource [ , forSource ]*
forSource ::= symbol in simpleExpr
| symbol := simpleExpr
| simpleExpr
forTest ::= while simpleExpr
| until simpleExpr
forBody ::= do expr
| collect [ into simpleExpr ] [ by factor ] [ as factor ] simpleExpr
| select factor [ into simpleExpr ] \
[ by factor ] [ as factor ] if simpleExpr
Definition of Classes
classDefExpr ::= class symbol ( supersList ) classBody end
supersList ::= simpleExpr [ , supersList ]*
classBody ::= [ classVars ] [ instanceVars ] [ classMethods ] [ instMethods ]
classVars ::= class var[iable]s varList
instanceVars ::= inst[ance] var[iable]s varList
varList ::= [ qualifiers ] variable moreVars
moreVars ::= [ endOfLine ]+ varList
| [ , varList ]*
qualifiers ::= [ readOnly ] [ transientOption ] [ reference ]
transientOption ::= transient [ initializer factor ]
classMethods ::= class methods methods
instMethods ::= inst[ance] methods methods
methods ::= methodDefExpr moreMethods
moreMethods ::= [ endOfLine ]* methods
objectDefExpr ::= object [ symbol ] ( [ classesList ] ) objectBody end
classesList ::= simpleExpr [ , classesList ]
objectBody ::= [ initialization ] [ instanceVars ] [ instMethods ] \
[ settings ] [ contents ]
initialization ::= initList | empty
initList ::= initForm moreInitForms
initForm ::= symbol : simpleExpr
moreInitForms ::= [ endOfLine ]+ initList
| [ , initList ]*
settings ::= settings initList
contents ::= contents contentsList
contentsList ::= simpleExpr moreContentForms
moreContentForms ::= [ endOfLine ]+ contentsList
| [ , contentsList ]*
functionDefExpr ::= f[unctio]n symbol [ argSeq ] body
| f[unctio]n symbol ( [ argList ] ) body
methodDefExpr ::= method [ getterOrSetter ] symbol argSeq body
freeMethDefExpr ::= [ class ] method [ getterOrSetter ] symbol argSeq body
anonFuncDefExpr ::= ( anonArgs -> compoundExprSeq )
body ::= -> expr
getterOrSetter ::= get | set
argSeq ::= [ positionalArgSeq ] [ restArg ] [ keywordArgSeq ]
argList ::= [ positionalArgList ] [ restArg ] [ keywordArgList ]
anonArgs ::= [ paramSequence ] [ restArg ] [ keywordArgSeq ]
| empty
positionalArgSeq ::= argument [ argument ]*
positionalArgList ::= argument [ , positionalArgList ]*
restArgs ::= #rest symbol
keywordArgSeq ::= #key keyArgPair [ keyArgPair ]*
keywordArgList ::= #key keyArgPair [ , keyArgPair ]*
argument ::= symbol [ restriction ]
keyArgPair ::= argument : [ symbol ] [ ( simpleExpr ) ]
inModuleExpr ::= in module symbol
moduleDefExpr ::= module symbol [ moduleOptions ] end
moduleOptions ::= [ moduleOption ]*
moduleOption ::= exports [ readonly ] [ inst[ance] var[iable]s ] symbolSeq
| uses symbolSeq
| uses symbol [ with usesOptions ] end
symbolSeq ::= symbol [ , symbol ]*
usesOptions ::= [ usesOption ]*
usesOption ::= imports everything
| imports [ readonly ] [ inst[ance] var[iable]s ] symbolSeq
| exports everything
| exports [ readonly ] [ inst[ance] var[iable]s ] symbolSeq
| prefix symbol
| excludes [ readonly ] [ inst[ance] var[iable]s ] symbolSeq
| renames [ readonly ] [ inst[ance] var[iable]s ] renameSeq
renameSeq ::= symbol : symbol [ , symbol : symbol ]*
guardExpr ::= guard expr [ catching catchList ] [ on exit expr ] end
catchList ::= catcher moreCatchers
moreCatchers ::= [ endOfLine ]* catchList
| [ endOfLine ]* moreCatchers
| empty
catcher ::= symbol [ symbol ] [ : expr ]
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.